
/*
 * Copyright 2002-2020 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 *版权所有2002-2020原作者。
 *
 *根据Apache许可证2.0版（“许可证”）获得许可；
 *除非符合许可证，否则不得使用此文件。
 *您可以在以下地址获取许可证副本：
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 *除非适用法律要求或书面同意，软件
 *根据许可证分发的内容是按“原样”分发的，
 *无任何明示或暗示的保证或条件。
 *有关管理权限和
 *许可证下的限制。
 */

package org.springframework.beans.factory.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * An annotation that indicates 'lookup' methods, to be overridden by the container
 * to redirect them back to the {@link org.springframework.beans.factory.BeanFactory}
 * for a {@code getBean} call. This is essentially an annotation-based version of the
 * XML {@code lookup-method} attribute, resulting in the same runtime arrangement.
 *
 * <p>The resolution of the target bean can either be based on the return type
 * ({@code getBean(Class)}) or on a suggested bean name ({@code getBean(String)}),
 * in both cases passing the method's arguments to the {@code getBean} call
 * for applying them as target factory method arguments or constructor arguments.
 *
 * <p>Such lookup methods can have default (stub) implementations that will simply
 * get replaced by the container, or they can be declared as abstract - for the
 * container to fill them in at runtime. In both cases, the container will generate
 * runtime subclasses of the method's containing class via CGLIB, which is why such
 * lookup methods can only work on beans that the container instantiates through
 * regular constructors: i.e. lookup methods cannot get replaced on beans returned
 * from factory methods where we cannot dynamically provide a subclass for them.
 *
 * <p><b>Recommendations for typical Spring configuration scenarios:</b>
 * When a concrete class may be needed in certain scenarios, consider providing stub
 * implementations of your lookup methods. And please remember that lookup methods
 * won't work on beans returned from {@code @Bean} methods in configuration classes;
 * you'll have to resort to {@code @Inject Provider<TargetBean>} or the like instead.
 *
 * @author Juergen Hoeller
 * @since 4.1
 * @see org.springframework.beans.factory.BeanFactory#getBean(Class, Object...)
 * @see org.springframework.beans.factory.BeanFactory#getBean(String, Object...)
 */
/**
 *指示“查找”方法的批注，将由容器重写
 *将它们重定向回｛@linkorg.springframework.beans.factory.BeanFactory｝
 *用于｛@code getBean｝调用。这本质上是基于注释的
 *XML｛@code lookup method｝属性，导致相同的运行时排列。
 *
 *＜p＞目标bean的解析可以基于返回类型
 *（{@code getBean（Class）}）或建议的bean名称（{@codegetBean（String）}），
 *在这两种情况下，都将方法的参数传递给｛@code getBean｝调用
 *用于将它们应用为目标工厂方法参数或构造函数参数。
 *
 *＜p＞这样的查找方法可以具有默认（存根）实现
 *被容器替换，或者它们可以声明为抽象的-对于
 *容器以在运行时填充它们。在这两种情况下，容器都将生成
 *通过CGLIB的方法的包含类的运行时子类，这就是为什么
 *查找方法只能在容器实例化的bean上工作
 *常规构造函数：即，在返回的bean上无法替换查找方法
 *在工厂方法中，我们无法动态地为它们提供子类。
 *
 *<p><b>针对典型Spring配置场景的建议：</b>
 *当特定场景中可能需要具体类时，请考虑提供存根
 *查找方法的实现。请记住查找方法
 *无法处理从配置类中的｛@code@Bean｝方法返回的Bean；
 *您将不得不求助于｛@code@InjectProvider＜TargetBean＞｝或类似方法。
 *
 *@作者Juergen Hoeller
 *@自4.1
 *@see org.springframework.beans.factory.BeanFactory#getBean（类，对象…）
 *@see org.springframework.beans.factory.BeanFactory#getBean（字符串，对象…）
 */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Lookup {

	/**
	 * This annotation attribute may suggest a target bean name to look up.
	 * If not specified, the target bean will be resolved based on the
	 * annotated method's return type declaration.
	 */
	/**
	 *此注释属性可能会建议查找目标bean名称。
	 *如果未指定，则将基于
	 *带注释方法的返回类型声明。
	 */
	String value() default "";

}
